{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Title: #Maximum Value of a String in an Array"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Difficulty: #Easy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Category Title: #Algorithms"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Tag Slug: #array #string"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Name Translated: #数组 #字符串"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solution Name: maximumValue"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Title: #数组中字符串的最大值"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Content:\n",
    "<p>一个由字母和数字组成的字符串的 <strong>值</strong>&nbsp;定义如下：</p>\n",
    "\n",
    "<ul>\n",
    "\t<li>如果字符串 <strong>只</strong> 包含数字，那么值为该字符串在 <code>10</code>&nbsp;进制下的所表示的数字。</li>\n",
    "\t<li>否则，值为字符串的 <strong>长度&nbsp;</strong>。</li>\n",
    "</ul>\n",
    "\n",
    "<p>给你一个字符串数组&nbsp;<code>strs</code>&nbsp;，每个字符串都只由字母和数字组成，请你返回 <code>strs</code>&nbsp;中字符串的 <strong>最大值</strong>&nbsp;。</p>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>示例 1：</strong></p>\n",
    "\n",
    "<pre>\n",
    "<strong>输入：</strong>strs = [\"alic3\",\"bob\",\"3\",\"4\",\"00000\"]\n",
    "<b>输出：</b>5\n",
    "<b>解释：</b>\n",
    "- \"alic3\" 包含字母和数字，所以值为长度 5 。\n",
    "- \"bob\" 只包含字母，所以值为长度 3 。\n",
    "- \"3\" 只包含数字，所以值为 3 。\n",
    "- \"4\" 只包含数字，所以值为 4 。\n",
    "- \"00000\" 只包含数字，所以值为 0 。\n",
    "所以最大的值为 5 ，是字符串 \"alic3\" 的值。\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 2：</strong></p>\n",
    "\n",
    "<pre>\n",
    "<b>输入：</b>strs = [\"1\",\"01\",\"001\",\"0001\"]\n",
    "<b>输出：</b>1\n",
    "<b>解释：</b>\n",
    "数组中所有字符串的值都是 1 ，所以我们返回 1 。</pre>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>提示：</strong></p>\n",
    "\n",
    "<ul>\n",
    "\t<li><code>1 &lt;= strs.length &lt;= 100</code></li>\n",
    "\t<li><code>1 &lt;= strs[i].length &lt;= 9</code></li>\n",
    "\t<li><code>strs[i]</code>&nbsp;只包含小写英文字母和数字。</li>\n",
    "</ul>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Description: [maximum-value-of-a-string-in-an-array](https://leetcode.cn/problems/maximum-value-of-a-string-in-an-array/description/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solutions: [maximum-value-of-a-string-in-an-array](https://leetcode.cn/problems/maximum-value-of-a-string-in-an-array/solutions/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_cases = ['[\"alic3\",\"bob\",\"3\",\"4\",\"00000\"]', '[\"1\",\"01\",\"001\",\"0001\"]']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        ans = 0\n",
    "        for i in strs:\n",
    "            if i.isdigit():\n",
    "                ans = max(ans, int(i))\n",
    "            else:\n",
    "                ans = max(ans, len(i))\n",
    "        return ans "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "\n",
    "# -*- coding: utf-8 -*-\n",
    "from typing import List, Tuple, Optional\n",
    "from collections import deque, Counter\n",
    "from queue import PriorityQueue\n",
    "import math\n",
    "from functools import lru_cache\n",
    "from sortedcontainers import SortedDict, SortedSet\n",
    "import random\n",
    "import copy\n",
    "import sys\n",
    "sys.setrecursionlimit(9999999)\n",
    "\n",
    "MOD = 10**9 + 7\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "\n",
    "        mx = -1\n",
    "        for w in strs:\n",
    "            f = False\n",
    "            for ch in w:\n",
    "                if ch not in '1234567890':\n",
    "                    f = True\n",
    "                    break\n",
    "\n",
    "            if f:\n",
    "                val = len(w)\n",
    "            else:\n",
    "                val = int(w)\n",
    "\n",
    "            mx = max(mx, val)\n",
    "\n",
    "        return mx"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        values = []\n",
    "        for s in strs:\n",
    "            if s.isdigit():\n",
    "                values.append(int(s))\n",
    "            else:\n",
    "                values.append(len(s))\n",
    "        return max(values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "\n",
    "    \n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "   \n",
    "        return max(int(s) if s.isdigit() else len(s) for s in strs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        res = 0\n",
    "        for s in strs:\n",
    "            is_digits = all(c.isdigit() for c in s)\n",
    "            res = max(res, int(s) if is_digits else len(s))\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        ret =[]\n",
    "        for str in strs:\n",
    "            if str.isdigit():\n",
    "                ret.append(int(str))\n",
    "            else:\n",
    "                ret.append(len(str))\n",
    "        return max(ret)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        x = 0\n",
    "        for i in strs:\n",
    "            if i.isdigit():\n",
    "                x = max(int(i), x)\n",
    "            else:\n",
    "                x = max(len(i), x)\n",
    "        return x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        ans=-inf\n",
    "        for i in strs:\n",
    "            if all(j in '1234567890' for j in i):\n",
    "                ans=max(ans,int(i))\n",
    "            else:\n",
    "                ans=max(ans,len(i))\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        c=0\n",
    "        for i in strs:\n",
    "            if all(j.isdigit() for j in i):\n",
    "                c=max(c,int(i))\n",
    "            else:\n",
    "                c=max(c,len(i))\n",
    "        return c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "      res = 0\n",
    "      for s in strs:\n",
    "        is_digits = all(c.isdigit() for c in s)\n",
    "        res = max(res, int(s) if is_digits else len(s))\n",
    "      return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "         res = 0\n",
    "         for s in strs:\n",
    "            is_digits = all(c.isdigit() for c in s)\n",
    "            res = max(res, int(s) if is_digits else len(s))\n",
    "         return res\n",
    "\n",
    "      "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        ans = [int(i) if i.isdigit() else len(i)  for i in strs]\n",
    "\n",
    "        return max(ans)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        ans = 0\n",
    "        for s in strs:\n",
    "            only_num = True\n",
    "            for c in s:\n",
    "                if c.isalpha():\n",
    "                    only_num = False\n",
    "                    break\n",
    "            ans = max(ans,int(s)) if only_num else max(ans,len(s))\n",
    "           \n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        res=0\n",
    "        for s in strs:\n",
    "            res=max(res,int(s) if s.isdigit() else len(s))\n",
    "        return res\n",
    "\n",
    "                \n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        res = 0\n",
    "        for s in strs:\n",
    "            if s.isdigit():\n",
    "                res = max(res, int(s))\n",
    "            else:\n",
    "                res = max(res, len(s))\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        res = 0\n",
    "        for s in strs:\n",
    "            is_digits = all(c.isdigit() for c in s)\n",
    "            res = max(res, int(s) if is_digits else len(s))\n",
    "        return res\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "         res = 0\n",
    "         for s in strs:\n",
    "            is_digits = all(c.isdigit() for c in s)\n",
    "            res = max(res, int(s) if is_digits else len(s))\n",
    "         return res\n",
    "\n",
    "      "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        ans=0\n",
    "        for str in strs:\n",
    "            f=0\n",
    "            for ch in str:\n",
    "                if ch<='z' and ch>='a':\n",
    "                    f=1\n",
    "                    break\n",
    "            if f:\n",
    "                ans=max(ans,len(str))\n",
    "            else:\n",
    "                ans=max(ans,int(str))\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        res = float(\"-inf\")\n",
    "        for s in strs:\n",
    "            if s.isdigit():\n",
    "                res = max(res,int(s))\n",
    "            else:\n",
    "                res = max(res,len(s))\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        ans = []\n",
    "        for i in strs:\n",
    "            if i.isdigit() == True:\n",
    "                temp = int(i)\n",
    "                ans.append(temp)\n",
    "            else:\n",
    "                ans.append(len(i))\n",
    "        return max(ans)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        ans = 0\n",
    "        for s in strs:\n",
    "            if s.isdigit():\n",
    "                ans = max(ans,int(s))\n",
    "            else:\n",
    "                ans = max(ans,len(s))\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "         return max(int(i)  if i.isdigit() else len(i) for i in strs)\n",
    "            \n",
    "                "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        ans = []\n",
    "        for i in strs:        \n",
    "            txt = True\n",
    "            for x in i:\n",
    "                if x not in '0123456789':\n",
    "                    ans += [len(i)]\n",
    "                    txt = False\n",
    "                    break\n",
    "            if txt:\n",
    "                ans += [int(i)]\n",
    "        return max(ans)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        res = 0\n",
    "        for s in strs:\n",
    "            is_digits = all(c.isdigit() for c in s)\n",
    "            res = max(res, int(s) if is_digits else len(s))\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        n = len(strs)\n",
    "        res = 0\n",
    "        for i in range(n):\n",
    "            if strs[i].isdigit():\n",
    "                value = int(strs[i])\n",
    "            else:\n",
    "                value = len(strs[i])\n",
    "            \n",
    "            if value > res:\n",
    "                res = value\n",
    "        \n",
    "        return res\n",
    "            \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        res = 0\n",
    "        for s in strs:\n",
    "            if s.isdigit():\n",
    "                res = max(res, int(s))\n",
    "            else:\n",
    "                res = max(res, len(s))\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        res = []\n",
    "        for s in strs:\n",
    "            if s.isdigit():\n",
    "                res.append(int(s))\n",
    "            else:\n",
    "                res.append(len(s))\n",
    "        return max(res)                "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        res = 0\n",
    "        for val in strs:\n",
    "            if val.isnumeric():\n",
    "                res = max(res, int(val))\n",
    "            else:\n",
    "                res = max(res, len(val))\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        return max(int(s) if s.isdigit() else len(s) for s in strs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        nl = '0123456789'\n",
    "\n",
    "        max_n = 0\n",
    "\n",
    "        for item in strs:\n",
    "            is_num = True\n",
    "            for s in item:\n",
    "                if s not in nl:\n",
    "                    is_num = False\n",
    "                    break\n",
    "            \n",
    "            cur_n = int(item) if is_num else len(item)\n",
    "            if cur_n > max_n:\n",
    "                max_n = cur_n\n",
    "        \n",
    "        return max_n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        def f(s: str) -> int:\n",
    "            return int(s) if all(c.isdigit() for c in s) else len(s)\n",
    "\n",
    "        return max(f(s) for s in strs)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        def value(s):\n",
    "            if all([c in '0123456789' for c in s]):\n",
    "                return int(s)\n",
    "            else:\n",
    "                return len(s)\n",
    "        return max([value(s) for s in strs])\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        max = -sys.maxsize-1\n",
    "        for item in strs:\n",
    "            if item.isdigit():\n",
    "                item = int(item)\n",
    "            else:\n",
    "                item = len(item)\n",
    "            if max < item:\n",
    "                max = item\n",
    "        return max"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        answer = []\n",
    "        for x in strs:\n",
    "            if x.isnumeric():\n",
    "               answer.append(int(x,10))\n",
    "            else:\n",
    "                answer.append(len(x))\n",
    "        return max(answer)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        ans=set()\n",
    "        for x in strs:\n",
    "            if bool(re.search('[a-zA-Z]', x)):\n",
    "                ans.add(len(x))\n",
    "            else:\n",
    "                ans.add(int(x))\n",
    "        return max(ans)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        num=0\n",
    "        for i in strs:\n",
    "            all_d=all(j.isdigit() for j in i)\n",
    "            num=max(num,int(i) if all_d else len(i))\n",
    "        return num"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        res = []\n",
    "        for s in strs:\n",
    "            # 判断是不是纯数字，如果是纯数字结果为true。\n",
    "            # int正好是把字符串转换成十进制数值\n",
    "            if s.isdigit():\n",
    "                res.append(int(s))\n",
    "            else:\n",
    "                res.append(len(s))\n",
    "        return max(res)                "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        def f(s:str) ->int:\n",
    "            return int(s) if all(c.isdigit() for c in s) else len(s)\n",
    "        return max(f(s) for s in strs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        return max(int(s) if s.isdigit() else len(s)\n",
    "                   for s in strs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        # sum=sum1=0\n",
    "        # for i in strs:\n",
    "        #     sum=len(i)\n",
    "        #     if i>'0' and i<'9':\n",
    "        #         sum1=ord('i')-ord('0')\n",
    "        #     if sum>sum1:\n",
    "        #         sum1=sum\n",
    "        # return sum1\n",
    "        res = 0\n",
    "        for value in strs:\n",
    "            tmp = 0\n",
    "            if self.is_num(value):\n",
    "                tmp = int(value)\n",
    "            else:\n",
    "                tmp = len(value)\n",
    "            res = max(res, tmp)\n",
    "        return res\n",
    "    \n",
    "    def is_num(self, data):\n",
    "        for value in data:\n",
    "            if not (value >= '0' and value <= '9'):\n",
    "                return False\n",
    "        return True\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        vl = []\n",
    "        for str in strs:\n",
    "            try:\n",
    "                vl.append(int(str))\n",
    "            except ValueError:\n",
    "                vl.append(len(str))\n",
    "        return max(vl)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        ans = 0\n",
    "        for s in strs:\n",
    "            tag = 0\n",
    "            for i in s:\n",
    "                if i in 'qwertyuiopasdfghjklzxcvbnm':\n",
    "                    tag = 1\n",
    "                    break\n",
    "            if tag == 0:\n",
    "                ans = max(ans, int(s))\n",
    "            else:\n",
    "                ans = max(ans, len(s))\n",
    "\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        return max([int(i) if i.isdigit() else len(i) for i in strs])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        res = 0\n",
    "        for s1 in strs:\n",
    "            if s1.isdigit():\n",
    "                res = max(res,int(s1))\n",
    "            else:\n",
    "                res = max(res,len(s1))\n",
    "                    \n",
    "        return res\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        def to_int(st):\n",
    "            try:\n",
    "                return int(st)\n",
    "            except:\n",
    "                return len(st)\n",
    "        return to_int(max(strs, key = to_int))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        res = 0\n",
    "        for s in strs:\n",
    "            is_digits = all(c.isdigit() for c in s)\n",
    "            res = max(res, int(s) if is_digits else len(s))\n",
    "        return res\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        res = 0\n",
    "        for s in strs:\n",
    "            is_digits = all(c.isdigit() for c in s)\n",
    "            res = max(res, int(s) if is_digits else len(s))\n",
    "        return res\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        l=[]\n",
    "        for s in strs:\n",
    "            try:\n",
    "                l.append(int(s))\n",
    "            except:\n",
    "                l.append(len(s))\n",
    "        return max(l)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        return max(int(s) if s.isdigit() else len(s) for s in strs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        ans = 0\n",
    "        for str in strs:\n",
    "            try:\n",
    "                num = int(str)\n",
    "            except ValueError:\n",
    "                num = len(str)\n",
    "            ans = max(num, ans)\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        def f(s: str) -> int:\n",
    "            return int(s) if all(c.isdigit() for c in s) else len(s)\n",
    "\n",
    "        return max(f(s) for s in strs)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        # sum=sum1=0\n",
    "        # for i in strs:\n",
    "        #     sum=len(i)\n",
    "        #     if i>'0' and i<'9':\n",
    "        #         sum1=ord('i')-ord('0')\n",
    "        #     if sum>sum1:\n",
    "        #         sum1=sum\n",
    "        # return sum1\n",
    "        res = 0\n",
    "        for value  in strs:\n",
    "            tmp = 0\n",
    "            if str.isnumeric(value):\n",
    "                tmp = int(value)\n",
    "            else:\n",
    "                tmp = len(value)\n",
    "            res = max(res, tmp)\n",
    "        return res\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        return max(int(s) if s.isdigit() else len(s) for s in strs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        count_max = 0\n",
    "        for date in strs:\n",
    "            try:\n",
    "                count_max = max(count_max, int(date))\n",
    "            except:\n",
    "                count_max = max(count_max, len(date))\n",
    "        \n",
    "        return count_max       "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: list[str]) -> int:\n",
    "        list_max=[]\n",
    "        for i in range(len(strs)):\n",
    "            flag1 = False\n",
    "            flag2=False\n",
    "            for j in strs[i]:\n",
    "                if j>='0' and j<='9':\n",
    "                    flag1=True\n",
    "                if j>='A' and j<='z':\n",
    "                    flag2=True\n",
    "            if flag1==True and flag2==False:\n",
    "                list_max.append(int(strs[i]))\n",
    "            else:\n",
    "                list_max.append(len(strs[i]))\n",
    "        return max(list_max)    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        ans = []\n",
    "        for str in strs:\n",
    "            if str.isdigit():\n",
    "                ans.append(int(str))\n",
    "            else:\n",
    "                ans.append(len(str))\n",
    "        return max(ans)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        aa = []\n",
    "        c = 0\n",
    "        for i in strs:\n",
    "            try:\n",
    "                aa.append(int(i))\n",
    "            except:\n",
    "                aa.append(len(i))\n",
    "        for i in aa:\n",
    "            if c < i:\n",
    "                c = i\n",
    "        return c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        ans = []\n",
    "        for i in strs:\n",
    "            try:\n",
    "                ans.append(int(i))\n",
    "            except ValueError:\n",
    "                ans.append(len(i))\n",
    "        return max(ans) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "\n",
    "        ans = 0\n",
    "\n",
    "        for tmp in strs:\n",
    "            if tmp.isdigit():\n",
    "\n",
    "                ans = max(ans,int(tmp))\n",
    "            else:\n",
    "                ans = max(ans,len(tmp))\n",
    "        return ans\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        longind = 0\n",
    "        longest = 0\n",
    "        for i in range(len(strs)):\n",
    "            if strs[i].isdigit():\n",
    "                length = int(strs[i])\n",
    "            else:\n",
    "                length = len(strs[i])\n",
    "            if length > longest:\n",
    "                longest = length\n",
    "                longind = i\n",
    "        return longest"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        ans = 0\n",
    "        for i in strs:\n",
    "            try:\n",
    "                ans = max(ans,int(i))\n",
    "            except:\n",
    "                ans = max(ans,len(i))\n",
    "        return ans"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        res = 0\n",
    "        for i in range(len(strs)):\n",
    "            flag = -1\n",
    "            for j in range(len(strs[i])):\n",
    "                if strs[i][j]>='a' and strs[i][j]<='z':\n",
    "                    flag = len(strs[i])\n",
    "                    break\n",
    "            if flag ==-1:\n",
    "                flag = int(strs[i])    \n",
    "            if flag>res:\n",
    "                res = flag\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        return max(int(s) if s.isnumeric() else len(s) for s in strs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        aa = []\n",
    "        c = 0\n",
    "        for i in strs:\n",
    "            try:\n",
    "                aa.append(int(i))\n",
    "            except:\n",
    "                aa.append(len(i))\n",
    "        for i in aa:\n",
    "            if c < i:\n",
    "                c = i\n",
    "        return c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        max_len=0\n",
    "        for x in strs:\n",
    "            if bool(re.search('[a-zA-Z]', x)):\n",
    "                max_len=max(max_len,len(x))\n",
    "            else:\n",
    "                max_len=max(max_len,int(x))\n",
    "        return max_len"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        res=[]\n",
    "        for i in strs:\n",
    "            if i.isalnum():\n",
    "                if i.isdigit():\n",
    "                    res.append(int(i))    \n",
    "                else:\n",
    "                    res.append(len(i))\n",
    "        return max(res)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        return max(int(s) if s.isdigit() else len(s)\n",
    "                   for s in strs)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def maximumValue(self, strs: List[str]) -> int:\n",
    "        ans = 0\n",
    "        for st in strs:\n",
    "            s = 0\n",
    "            for i in st:\n",
    "                if ord(i) < 47 or ord(i) > 58:\n",
    "                    s = 1\n",
    "                    break\n",
    "            if s == 1:\n",
    "                ans = max(ans, len(st))\n",
    "            elif s == 0:\n",
    "                ans = max(ans, int(st))\n",
    "        return ans"
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
